import http from "../request";
const apibase = "/api/Route";
import qs from 'qs'

//查询工艺
var getrouteList = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/GetRouteList`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//查询产品工艺
var getrouteListtomaterialCode = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/GetRouteListToMaterialCode`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//查询工艺的工序
var getstdoperationtorouteID = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/GetStdOperationToRouteID?RouteID=${data}`,)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//查询工艺工序的SOP
var getSop = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/GetSOP?${qs.stringify(data)}`,)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//新增
var insRoute = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/InsRoute`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//修改
var updRoute = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/UpdRoute`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//审核
var verify = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/verify`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//反审核
var deverify = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/Deverify`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//复制
var copyRoute = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/CopyRoute`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//启用
var defaultRoute = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/DefaultRoute`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};

//下载工艺模板
var routeTemplateDownload = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/RouteTemplateDownload`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
//导入工艺模板
var importRoute = function (data) {
  return new Promise((resolve, reject) => {
    http
      .Filepost(apibase + `/ImportRoute`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};
export { getrouteList, getrouteListtomaterialCode, getstdoperationtorouteID, getSop, insRoute, updRoute, verify, deverify, copyRoute, defaultRoute, importRoute, routeTemplateDownload };
